package com.asimplefox.configs;

import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;

/**
 * c代理
 * @author github.kloping
 */
@Getter
@Component
@ConditionalOnProperty(value = {"proxy.host", "proxy.port"})
@Slf4j
public class ProxyConfig {

    public final String host;
    public final Integer port;

    public ProxyConfig(@Value("${proxy.host}") String host,
                       @Value("${proxy.port}") Integer port) {
        System.setProperty("http.proxyHost", host);
        System.setProperty("http.proxyPort", port.toString());
        this.host = host;
        this.port = port;
        log.warn("ProxyConfig init: {}:{}", host, port);
    }
}
